package com.example.controller;

import com.example.domain.User;
import com.example.service.LoginService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class LoginController {
    @Autowired
    private LoginService loginService;

    @PostMapping("/login")
    public Result login(@RequestBody User user) {
        User u = loginService.login(user);
        if (u != null) {
            return Result.success(u);
        }
        else {
            return Result.failure(400,"登录失败，请重试！");
        }
    }
}
